package GUI.Admin;

import GUI.System.GUIFrame;

/**
 * Control panel for the administrator.
 */
public class ControlPanel extends javax.swing.JPanel {

    private GUIFrame frame;

    /**
     * Custom constructor which initializes the panel's components.
     */
    public ControlPanel() {
        initComponents();
    }

    /**
     * Setter for GUIFrame reference.
     *
     * @param frame GUIFrame object.
     */
    public void setFrame(GUIFrame frame) {
        this.frame = frame;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labTitle = new javax.swing.JLabel();
        btnAccManage = new javax.swing.JButton();
        btnTransManage = new javax.swing.JButton();
        btnLogout = new javax.swing.JButton();
        labAccManage = new javax.swing.JLabel();
        labTransManage = new javax.swing.JLabel();
        labTermManage = new javax.swing.JLabel();
        btnTermManage = new javax.swing.JButton();

        labTitle.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        labTitle.setText("Administrator Control Panel");

        btnAccManage.setText("Account Management");
        btnAccManage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAccManageActionPerformed(evt);
            }
        });

        btnTransManage.setText("Transaction Management");
        btnTransManage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTransManageActionPerformed(evt);
            }
        });

        btnLogout.setText("Logout");
        btnLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLogoutActionPerformed(evt);
            }
        });

        labAccManage.setText("Edit customers account details.");

        labTransManage.setText("Manage billings and deposits.");

        labTermManage.setText("Manage terminal statuses.");

        btnTermManage.setText("Terminal Manager");
        btnTermManage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTermManageActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(btnTransManage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnAccManage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnTermManage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(labAccManage, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(labTransManage)
                                    .addComponent(labTermManage, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnLogout)))
                .addGap(37, 37, 37))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(labTitle)
                .addGap(47, 47, 47)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAccManage)
                    .addComponent(labAccManage))
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnTransManage)
                    .addComponent(labTransManage))
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labTermManage)
                    .addComponent(btnTermManage))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
                .addComponent(btnLogout)
                .addGap(38, 38, 38))
        );
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Change to the log-in panel.
     *
     * @param evt ActionEvent
     */
    private void btnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogoutActionPerformed
        frame.cManager.setLoggedInUser(null);
        frame.changePanel("card1");
    }//GEN-LAST:event_btnLogoutActionPerformed

    /**
     * Change panel to allow administrator to log in as another customer.
     *
     * @param evt ActionEvent
     */
    private void btnAccManageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAccManageActionPerformed
        frame.changePanel("card12");
    }//GEN-LAST:event_btnAccManageActionPerformed

    /**
     * Change to transaction administrator-view.
     *
     * @param evt ActionEvent
     */
    private void btnTransManageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTransManageActionPerformed
        frame.changePanel("card25");
    }//GEN-LAST:event_btnTransManageActionPerformed

    /**
     * Change to view list of all terminals as administrator.
     *
     * @param evt ActionEvent
     */
    private void btnTermManageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTermManageActionPerformed
        frame.changePanel("card19");
    }//GEN-LAST:event_btnTermManageActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAccManage;
    private javax.swing.JButton btnLogout;
    private javax.swing.JButton btnTermManage;
    private javax.swing.JButton btnTransManage;
    private javax.swing.JLabel labAccManage;
    private javax.swing.JLabel labTermManage;
    private javax.swing.JLabel labTitle;
    private javax.swing.JLabel labTransManage;
    // End of variables declaration//GEN-END:variables
}
